﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace GGJ.Sprites
{
    public class KilledFlies
    {
        private List<Fly> killedFlies;
        private Texture2D flySprites;
        private int lost = 0;

        public KilledFlies(Texture2D flySprites)
        {
            this.flySprites = flySprites;
            killedFlies = new List<Fly>();
        }

        public void registeredLost()
        {
            lost++;
        }

        public int getLost()
        {
            return killedFlies.Count + lost;
        }

        public void removeFly(int i)
        {
            killedFlies.RemoveAt(i);
            lost++;
        }

        public void AddFly(Fly fly)
        {

            killedFlies.Add(fly);
        }
        public void Update(GameTime gameTime, Flies flies, bool isSlowMotion)
        {

            float realSpeed = Program.speedFlies;

            if (isSlowMotion)
                realSpeed = realSpeed / 2;

            for (int i = 0; i < killedFlies.Count; i++)
            {
                killedFlies[i].Update(gameTime, FliesMovement.Dead, realSpeed, isSlowMotion);

                if (killedFlies[i].isOutOfGame())
                {
                    killedFlies.RemoveAt(i);
                }
               
            }

        }

        public void Draw(SpriteBatch spriteBatch)
        {
            foreach (Fly fly in killedFlies)
            {
                fly.Draw(spriteBatch,Fly.type.civil);
            }
        }
    }
}
